package com.art.base.commonui;

import com.art.base.util.log.LogUtil;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * @functionName:
 * @Package com.art.mp.base
 * @author dongtianhao
 * @date 2016年6月12日 下午4:45:11
 * @version V1.0
 * @Description:基础fragment
 */
public class IBaseFragment extends Fragment {
	protected static String TAG = "ART_BASE_F";
	protected Toolbar toolbar;
	protected View view;
	protected Intent intent;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		return super.onCreateView(inflater, container, savedInstanceState);
	}

	/** 初始化视图 **/
	protected void initViews(View view) {

	}

	/** 初始化事件 **/
	protected void initEvents(View view) {
	}

	/**
	 * 加载数据
	 */
	protected void initData() {

	}

	/** 通过Class跳转界面 **/
	protected void startActivity(Class<?> cls) {
		startActivity(cls, null);
	}

	/** 通过Action跳转界面 **/
	protected void startActivity(String action) {
		startActivity(action, null);
	}

	/** 含有Bundle通过Action跳转界面 **/
	protected void startActivity(String action, Bundle bundle) {
		intent = new Intent();
		intent.setAction(action);
		if (bundle != null) {
			intent.putExtras(bundle);
		}
		startActivity(intent);
	}

	/** 含有Bundle通过Class跳转界面 **/
	protected void startActivity(Class<?> cls, Bundle bundle) {
		intent = new Intent();
		intent.setClass(getActivity(), cls);
		if (bundle != null) {
			intent.putExtras(bundle);
		}
		startActivity(intent);
	}

	protected void d(String msg) {
		LogUtil.trace(Log.DEBUG, TAG, msg);
	}

	/**
	 * 
	 * @Title: d
	 * @Description: debug输出
	 * @param msg
	 *            输出消息
	 * @param isContinueWrite
	 *            :默认是true，即是上面没有这个参数的方法， 表示继续在原有文件写入，如果是false则创建一个新的覆盖原来的它。
	 * @throws
	 */
	protected void d(String msg, boolean isContinueWrite) {
		LogUtil.trace(Log.DEBUG, TAG, msg, isContinueWrite);
	}

	protected void e(String msg) {
		LogUtil.trace(Log.ERROR, TAG, msg);
	}

	protected void e(String msg, boolean isContinueWrite) {
		LogUtil.trace(Log.ERROR, TAG, msg);
	}

	protected void w(String msg) {
		LogUtil.trace(Log.WARN, TAG, msg);
	}

	protected void w(String msg, boolean isContinueWrite) {
		LogUtil.trace(Log.WARN, TAG, msg);
	}

	protected void i(String msg) {
		LogUtil.trace(Log.INFO, TAG, msg);
	}

}
